<p>在多线程环境中使用java库中的非线程安全类可能会在运行时导致数据问题或异常。</p>
<p>比如静态的<code> Calendar </code>，<code> DateFormat </code>，<code> javax.xml.xpath.XPath </code>或<code> javax.xml.validation.SchemaFactory </code>等类。</p>
<h2>不规范的代码示例</h2>
<pre>
public class MyClass {
  static private SimpleDateFormat format = new SimpleDateFormat("HH-mm-ss");  // Noncompliant
  static private Calendar calendar = Calendar.getInstance();  // Noncompliant
</pre>

<h2>正确的代码示例</h2>
<pre>
public class MyClass {
  private SimpleDateFormat format = new SimpleDateFormat("HH-mm-ss");
  private Calendar calendar = Calendar.getInstance();
</pre>

